package com.choosefine.base.shixiaobao.basedata.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.choosefine.base.shixiaobao.base.BaseService;
import com.choosefine.base.shixiaobao.basedata.dao.AttendanceDepartmentMapper;
import com.choosefine.base.shixiaobao.basedata.dao.AttendanceStaffMapper;
import com.choosefine.base.shixiaobao.basedata.model.AttendanceStaff;
import com.choosefine.base.shixiaobao.common.def.CommonConstant;

/**
 * Comments：考勤-员工
 * Author：xiongchao
 * Create Date：Jul 26, 2017
 * Modified By：
 * Modified Date：
 * Why & What is modified：
 * Version：v1.0
 */
@Service("AttendanceStaffService")
public class AttendanceStaffService extends BaseService {
	@Autowired
	AttendanceStaffMapper attendanceStaffMapper;
	@Autowired
	AttendanceDepartmentMapper attendanceDepartmentMapper;
	
	public int save(AttendanceStaff attendanceStaff) throws Exception {
		int id = attendanceStaffMapper.insert(attendanceStaff);
		//attendanceStaff.getDepartmentId();
		return id;
	}
	
	public int update(AttendanceStaff attendanceStaff) throws Exception {
		return attendanceStaffMapper.updateByPrimaryKeySelective(attendanceStaff);
	}
	
	public int delete(Integer[] ids) throws Exception {
		int num = 0;
		for (Integer id: ids) {
			AttendanceStaff staff = new AttendanceStaff();
			staff.setId(id);
			staff.setIsValid(CommonConstant.INVALID);
			num += attendanceStaffMapper.updateByPrimaryKeySelective(staff);
		}
		return num;
	}
}
